const Home = () => import('@/pages/Home')
const Login = () => import('@/pages/Login')
const Register = () => import('@/pages/Register')
const Search = () => import('@/pages/Search')
const Detail = () => import('@/pages/Detail')
const addCartSuccess = () => import('@/pages/AddCartSuccess')
const ShopCart = () => import('@/pages/ShopCart')
const Trade = () => import('@/pages/Trade')
const Pay = () => import('@/pages/Pay')
const PaySuccess = () => import('@/pages/PaySuccess')
const Center = () => import('@/pages/Center')
export default [
    {
        path: '/',
        redirect: '/home'
    },
    {
        path: '/home',
        name: 'home',
        component: Home
    },
    {
        path: '/login',
        name: 'login',
        component: Login,
        meta: {
            isHidden: true
        }
    },
    {
        path: '/register',
        name: 'register',
        component: Register,
        meta: {
            isHidden: true
        }
    },
    {
        path: '/search/:keyword?',
        name: 'search',
        component: Search
    },
    {
        path: '/detail/:skuId',
        name: 'detail',
        component: Detail,
        beforeEnter: (to, from, next) => {
            if (from.name === 'search') next()
            else next('/search')
        }
    },
    {
        path: '/addcartsuccess',
        name: 'addcartsuccess',
        component: addCartSuccess,
        beforeEnter: (to, from, next) => {
            if (from.name === 'detail') next()
            else next('/search')
        }
    },
    {
        path: '/shopcart',
        name: 'shopcart',
        component: ShopCart
    },
    {
        path: '/trade',
        name: 'trade',
        component: Trade,
        beforeEnter: (to, from, next) => {
            if (from.name === 'shopcart') next()
            else next('/shopcart')
        }
    },
    {
        path: '/pay',
        name: 'pay',
        component: Pay,
        beforeEnter: (to, from, next) => {
            if (from.name === 'trade') next()
            else next('/shopcart')
        }
    },
    {
        path: '/paysuccess',
        name: 'paysuccess',
        component: PaySuccess,
        beforeEnter: (to, from, next) => {
            if (from.name === 'pay') next()
            else next('/shopcart')
        }
    },
    {
        path: '/center',
        // name: 'center',
        component: Center,
        redirect: "/center/myorder",
        children: [
            {
                path: 'myorder',
                name: 'myorder',
                component: () => import("@/pages/Center/components/myOrder")
            },
            {
                path: 'teamorder',
                name: 'teamorder',
                component: () => import("@/pages/Center/components/teamOrder")
            }
        ]

    },
]